#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<long long>> arr(n + 1, vector<long long>(m + 1));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int temp;
            cin >> temp;
            arr[i][j] = arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1] + temp;
        }
    }
    int x1, x2, y1, y2;
    while (q--)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        x1 -= 1;
        y1 -= 1;
        cout << arr[x2][y2] - arr[x2][y1] - arr[x1][y2] + arr[x1][y1] << endl;
    }
    return 0;
}